public OnPlayerSpawn(playerid) {
	playerData[playerid][isSpawned] = true;
    PlayerPlaySound(playerid, 4807, 0.0, 0.0, 0.0);
	
    if (playerData[playerid][isReAdded]) {
        CBase::addPlayer(playerid);
        CPlayer::SetUpPingText(playerid);
       
        playerData[playerid][isReAdded] = false;
        return true;
    }
    
	if (playerData[playerid][isSyncSpawn]) {
		SetPlayerPos(playerid, playerData[playerid][syncX], playerData[playerid][syncY], playerData[playerid][syncZ]);
		SetPlayerFacingAngle(playerid, playerData[playerid][syncA]);
		SetPlayerHealth(playerid, playerData[playerid][syncHealth]);
		SetPlayerArmour(playerid, playerData[playerid][syncArmour]);
		
		ResetPlayerWeapons(playerid);
		
		for (new i; i < 12; i++) 
			GivePlayerWeapon(playerid, playerData[playerid][syncWeapons][i], playerData[playerid][syncAmmo][i]);
		
		SetPlayerInterior(playerid, playerData[playerid][syncInterior]);
		SetPlayerVirtualWorld(playerid, playerData[playerid][syncWorld]);
		
		SendClientMessage(playerid, C_YELLOW, "Synchronized!");
		CPlayer::SetUpPingText(playerid);
		playerData[playerid][isSyncSpawn] = false;
		SetCameraBehindPlayer(playerid);
		
		// If someone spectates the player, we have to update this.
		loop_players(i) {
			if (playerData[i][spectateId] == playerid) {
				CPlayer::Unspectate(i);
				SetTimerEx("alias_Spectate", 1500, false, "ddb", i, playerid, true);
			}
		}
	
		return true;
	}
	
	if (!playerData[playerid][isDMSpawn]) {
        new Float:fRdom = float(random(25)),
			Float:fPos[4] = {-2332.69, -1577.72, 483.57, 233.41}; 
			
        SetPlayerInterior(playerid, 0);
		SetPlayerPos(playerid, (fPos[0] - fRdom), (fPos[1] - (fRdom * 2)), fPos[2] + 1);
		SetPlayerFacingAngle(playerid, fPos[3]);
		ClearAnimations(playerid);
		SetCameraBehindPlayer(playerid);
		SetPlayerVirtualWorld(playerid, 0);
		ResetPlayerWeapons(playerid);
		SetPlayerHealth(playerid, 100.0);
		SetPlayerArmour(playerid, 100.0);
		
		GivePlayerWeapon(playerid, 34, 2000);
		GivePlayerWeapon(playerid, 31, 2000);
		GivePlayerWeapon(playerid, 29, 2000);
		GivePlayerWeapon(playerid, 25, 2000);
		GivePlayerWeapon(playerid, 24, 2000);
		
		playerData[playerid][activeDM] = -1;
	}
	
	else if (playerData[playerid][activeDM] > -1 && playerData[playerid][isDMSpawn]) {
		CDM::playerSet(playerid, playerData[playerid][activeDM]);
		SendClientMessage(playerid, C_YELLOW, "* You auto rejoined the deathmatch, type '/exit' to spawn in the lobby again.");
	}
	
	if (playerData[playerid][isDuel]) {
		duelData[iDuelCount] = 4;
		CDuel::DuelCount();
	}
	
	CPlayer::SetUpPingText(playerid);
	CPlayer::SixteentoNine(playerid, false);
	CPlayer::UpdatePlayerColor(playerid);
	CPlayer::ResetMapIcon(playerid);
	CPlayer::ShowTextDraws(playerid);
	
	if (gameData[bIsRoundActive]) {
		TextDrawShowForPlayer(playerid, textDraw[baseInfo]);
		TextDrawShowForPlayer(playerid, textDraw[barDes][TEAM_HOME]);
		TextDrawShowForPlayer(playerid, textDraw[barDes][TEAM_AWAY]);
        TextDrawShowForPlayer(playerid, textDraw[healLost][TEAM_HOME]);
        TextDrawShowForPlayer(playerid, textDraw[healLost][TEAM_AWAY]);
				
		ShowProgressBarForPlayer(playerid, textDraw[healthBar][TEAM_HOME]);
		ShowProgressBarForPlayer(playerid, textDraw[healthBar][TEAM_AWAY]);
	}
	
	else
		CPlayer::ShowLobbyDraws(playerid);
	
	// If someone spectates the player, we have to abort this.
	loop_players(i) {
		if (playerData[i][spectateId] == playerid) {
			CPlayer::Unspectate(i);
		}
	}
	
	return true;
}